package com.hr;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.googlecode.cswish.annotation.Rest;
import com.googlecode.cswish.model.PageInfo;
import com.googlecode.cswish.struts.spring.GenericService;

@Service
public class SalaryTicketLateItemService {
	
	@Resource
	GenericService genericService;
	
	@Resource
	SalaryTicketService salaryTicketService;

	@Rest(simpleServiceName="loginUser", type="free")
	public PageInfo searchRelatedResult(Salary model){
		if (model == null || model.getId() == null) return null;
		model = genericService.load(model);
		if (model == null) return null;
		
		SalaryTicket salaryTicket = salaryTicketService.getSalaryTicket(model.getEmployee().getId(), model.getAcctTerm());
		salaryTicket.setId(model.getId());
		
		List data = salaryTicket.getLateItems();
		if (data != null){
			PageInfo page = new PageInfo(data);
			page.setPageSize(data.size());
			return page;
		} else {
			return null;
		}
		
	}
}
